package lab3;

public class SortedList implements ISortedList {
	
	int val;
	ISortedList next;
	
	public SortedList( int i, ISortedList next ){
		this.val = i;
		this.next = next;
	}

	@Override
	public ISortedList addElt(int i) {
		if( i > val )
			return new SortedList(this.val, next.addElt(i));
		
		return new SortedList(i, this);
	}

	@Override
	public int size() {
		return 1 + next.size();
	}
	
	public String toString(){
		return val + ", " + next.toString();
	}

}
